import pageRoutes from '../../../config/router.config';

// 根据路由生成菜单
const menu = {
  'menu.home': '首页',
};
const data = pageRoutes[pageRoutes.length - 1].routes;
for (let i = 0; i < data.length; i += 1) {
  const item = data[i];
  const { name, routes } = item;
  if (name) {
    let pathName = 'menu.' + name;
    menu[pathName] = name;

    if (routes) {
      // 当前路由包含下级子路由
      pathName += '.';
      for (let j = 0; j < routes.length; j += 1) {
        const itemSub = routes[j];
        const { name } = itemSub;
        menu[pathName + name] = name;
      }
    }
  }
}
export default menu;
